# Copyright 1999-2013 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Header: $

EAPI=8
PYTHON_COMPAT=( python3_{6..14} )
DISTUTILS_USE_PEP517=setuptools

inherit linux-info distutils-r1 git-r3

DESCRIPTION="Ensures only some optimized harddisk layouts are used."
HOMEPAGE="https://gitee.com/your-own-os/strict_hdds"
EGIT_REPO_URI="https://gitee.com/your-own-os/strict_hdds.git"

LICENSE="GPLv3"
SLOT="0"
KEYWORDS="~amd64 ~ppc ~x86 ~amd64-linux ~x86-linux"
IUSE="bcachefs btrfs ntfs device-mapper"

DEPEND="dev-python/setuptools[${PYTHON_USEDEP}]"
RDEPEND="dev-python/crcmod
         dev-python/pyparted
         dev-python/pyudev
         dev-python/psutil
         sys-fs/dosfstools
         bcachefs? ( sys-fs/bcachefs-tools )
         btrfs? ( sys-fs/btrfs-progs )
         ntfs? ( sys-fs/ntfs3g )"

pkg_pretend() {
        local CONFIG_CHECK="~BCACHE ~EXT4_FS ~VFAT_FS"
        use btrfs && CONFIG_CHECK+=" ~BTRFS_FS"
        use ntfs && CONFIG_CHECK+=" ~NTFS3_FS"
        check_extra_config
}

src_prepare() {
        eapply_user
        if ! use bcachefs ; then
                rm -rf ${WORKDIR}/${P}/python3/strict_hdds/layout_*_bcachefs*.py
        fi
        if ! use btrfs ; then
                rm -rf ${WORKDIR}/${P}/python3/strict_hdds/layout_*_btrfs*.py
        fi
        if ! use ntfs ; then
                rm -rf ${WORKDIR}/${P}/python3/strict_hdds/layout_*_ntfs*.py
        fi
}
